$(function(){
	/*/!*手机号码验证*!/
	jQuery.validator.addMethod("mobile", function(value, element) {
		var length = value.length;
		var mobile = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/
		return this.optional(element) || (length == 11 && mobile.test(value));
	}, "手机号码格式错误");*/
	// 身份证号码验证
	jQuery.validator.addMethod("isIdCardNo", function(value, element) {
		var idCard = /^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\w)$/;
		return this.optional(element) || (idCard.test(value));
	}, "请输入正确的身份证号码!");
	//数字验证
	$.validator.addMethod("isPositive",function(value,element){
		var score = /^[0-9]*$/;
		return this.optional(element) || (score.test(value));
	},"请输入大于0的数字");

	jQuery.validator.addMethod("nowDate", function(value, element) {
			return new Date() <= new Date(Date.parse(value.replace("-", "/")));
		},
		"时间不能早于当前时间");

	/*验证*/
	$("#form-member-add").validate({
		submitHandler : function (form) {
			$("#form-member-add").ajaxSubFrom(form);
			return false;
			//$("#ajaxFromCreateUser").submit();
		},
		rules: {
			name: {
				required: true,
				rangelength:[6,20]
				//mobile:true
			},
			refereeNumber: {
				required: true
			},
			custerSource: {
				required: true
			},
			accountName: {
				required: true
			}
,
			realName: {
				required: true
			},
			idNumber: {
				required: true,
				isIdCardNo:true
				//rangelength:[16,18]
			},
			email: {
				required: true,
				email:true
			},
			mobile: {
				required: true
			},
			cardAphoto: {
				required: true
			},
			cardBphoto: {
				required: true
			}

		},
		messages: {
			name: {
				required: '用户名不得为空',
				rangelength:"用户名为6-20位字母或数字字母组合"
			},
			refereeNumber: {
				required: '请填写推荐人编号'
			},
			custerSource: {
				required: '请输入客户来源'
			},
			accountName: {
				required: '请输入账户名'
			},
			realName: {
				required: '请填写推荐人编号'
			},
			idNumber: {
				required: '请输入身份证号码'
				//rangelength:'请输入正确的身份证号码'
			},
			email: {
				required: '请输入邮箱',
				email:'请输入正确邮箱'
			},
			mobile: {
				required: '请输入手机号码'
			},
			cardAphoto: {
				required: '请上传身份证照片'
			},
			cardBphoto: {
				required: '请上传身份证照片'
			}
		},
			errorClass:'error_list'
			//错误提示位置
			//errorPlacement: function(error, element) {
			//error.appendTo(element.parent());
			//}
	});
});